package cn.chenhongchao.zhaobiaopingtai.controller;

import cn.chenhongchao.zhaobiaopingtai.common.api.CommonPage;
import cn.chenhongchao.zhaobiaopingtai.common.api.CommonResult;
import cn.chenhongchao.zhaobiaopingtai.dto.ReturnBidDTO;
import cn.chenhongchao.zhaobiaopingtai.entity.BusinessBid;
import cn.chenhongchao.zhaobiaopingtai.entity.WinBidApproval;
import cn.chenhongchao.zhaobiaopingtai.service.impl.BidServiceImpl;
import cn.chenhongchao.zhaobiaopingtai.service.impl.TenderServiceImpl;
import cn.chenhongchao.zhaobiaopingtai.service.impl.TenderWinServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/tenderWin")
public class TenderWinController {

    @Autowired
    private TenderWinServiceImpl tenderWinService;

    @Autowired
    private BidServiceImpl bidService;

    @RequestMapping("/getWinByTender")
    public CommonResult getTenderReturn(@RequestParam(value = "page", required = false) Integer pageNum,
                                        @RequestParam(value = "size", required = false) Integer pageSize,
                                        @RequestBody ReturnBidDTO returnBidDTO) {

        if (pageNum == null) {
            pageNum = 1;
        }

        if (pageSize == null) {
            pageSize = 1;
        }

        // 查询带了数据 需要动态查询  mybatis-plus
        CommonPage<WinBidApproval> returnBidCommonPage = bidService.getWinByTender(pageNum, pageSize, returnBidDTO);
        return CommonResult.success(returnBidCommonPage);

    }

}
